// 美的接口实例
import { config } from '../../config';
import { PlatformStrategy } from '../PlatformStrategy';
import { MideaReal } from './MideaReal';
import { MideaMock } from './MideaMock';

export class MideaStrategy implements PlatformStrategy {
  private impl: PlatformStrategy;

  constructor() {
    this.impl = config.useMockAPI ? new MideaMock() : new MideaReal();
  }

  exchangeToken(code: string) {
    return this.impl.exchangeToken(code);
  }

  revokeToken(access_token: string): Promise<void> {
    return this.impl.revokeToken(access_token);
  }

  refreshToken(userId: string, oldToken: string): Promise<{ access_token: string; expires_in: number }> {
    return this.impl.refreshToken(userId, oldToken);
  }

  getDeviceList(accessToken: string): Promise<{ did: string; name: string; type: string; online: boolean}[]>{
    return this.impl.getDeviceList(accessToken);
  }

  subscribeDevice(accessToken: string, deviceId: string): Promise<void> {
    return this.impl.subscribeDevice(accessToken, deviceId);
  }

  revokeDeviceSubscription(userId: string, did: string):Promise<void>{
    return  this.impl.revokeDeviceSubscription(userId, did);
  }


}
